{extend name="./view/base/admin.html"}
{block name="head"}
<style>
    .timeline:before {
        content: '';
        position: absolute;
        top: 5px;
        bottom: 5px;
        width: 5px;
        background: #e8eaec;
        left: 20%;
        margin-left: -2.5px;
    }

    .timeline .timeline-icon a {
        text-decoration: none;
        width: 20px;
        height: 20px;
        display: inline-block;
        background: #eee;
        line-height: 10px;
        color: #fff;
        font-size: 14px;
        border: 5px solid #2d8cf0;
        -webkit-transition: border-color .2s linear;
        -moz-transition: border-color .2s linear;
        -ms-transition: border-color .2s linear;
        -o-transition: border-color .2s linear;
        transition: border-color .2s linear;
        -webkit-border-radius: 16px;
        border-radius: 16px;
    }
</style>
{/block}
{block name="body"}
<div class="row">
    <div class="col-6">
        <div class="card">
            <div class="card-header">系统更新</div>
            <div class="card-body">
                <p>本地框架版本:v{:config('jsuphp.version')}</p>
                <p>线上框架版本:v{$server_version}</p>
                <div class="alert alert-primary">
                    <h4>检测更新说明</h4>
                    <div>文件差异：由于误操作删除了系统文件或系统更新导致的文件缺失和差异，请及时下载更新</div>
                    <div>脚本更新：如果与上次更新脚本数据不统一，请及时更新，如未发生变化则无需更新。</div>
                </div>
                <div class="alert alert-pink" v-if="sqls">
                    <h3>更新脚本</h3>
                    {{sqls}}个
                </div>
                <div class="alert alert-pink" v-if="files.length">
                    <h3>更新文件</h3>
                    <p class="mb-1" v-for="v in files" v-text="v.path"></p>
                </div>
                {if $server_version>config('jsuphp.version')}
                <button class="btn btn-lg btn-yellow" v-if="!files.length && !sqls" @click.prevent="upgrade_check">检查更新</button>
                <button class="btn btn-lg btn-pink" v-if="files.length || sqls" @click.prevent="upgrade_install">立即更新</button>
                {/if}
            </div>
        </div>
    </div>
    <div class="col-6">
        <div class="card">
            <div class="card-header">更新日志</div>
            <div class="card-body">
                <ul class="timeline">
                    {if count($upgrade_log)==0}
                    暂无更新日志
                    {else}
                    {foreach $upgrade_log as $v}
                    <li>
                        <!-- begin timeline-icon -->
                        <div class="timeline-icon">
                            <a href="javascript:;">&nbsp;</a>
                        </div>
                        <!-- end timeline-icon -->
                        <!-- begin timeline-body -->
                        <div class="timeline-body">
                            <div class="timeline-header">
                                <span class="username">V{$v.version}</span>
                                <span class="views">{$v.create_time}</span>
                            </div>
                            <div class="timeline-content">
                                {if count($v.add_content)&&$v.add_content[0]}
                                <p><i class="iconfont icon-zengjia mr-1 text-info"></i>新增功能</p>
                                <div class="m-b-10">
                                    {foreach $v.add_content as $v1}
                                    <p><span class="label label-info mr-1">新增</span>{$v1}</p>
                                    {/foreach}
                                </div>
                                {/if}
                                {if count($v.youhua_content)&&$v.youhua_content[0]}
                                <p><i class="iconfont icon-queding mr-1 text-purple"></i>优化功能</p>
                                <div class="m-b-10">
                                    {foreach $v.youhua_content as $v1}
                                    <p><span class="label label-purple mr-1">优化</span>{$v1}</p>
                                    {/foreach}
                                </div>
                                {/if}
                                {if count($v.edit_content)&&$v.edit_content[0]}
                                <p><i class="iconfont icon-icon_xinyong_xianxing_jijin- mr-1 text-pink"></i>修复功能</p>
                                <div class="m-b-10">
                                    {foreach $v.edit_content as $v1}
                                    <p><span class="label label-pink mr-1">修复</span>{$v1}</p>
                                    {/foreach}
                                </div>
                                {/if}
                                <p>备注:</p>
                                <div class="m-b-10">
                                    <p>{$v.desc}</p>
                                </div>
                            </div>
                        </div>
                        <!-- end timeline-body -->
                    </li> 
                    {/foreach}
                    {/if}
                </ul>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script>
    new Vue({
        el:'#content',
        data(){
            return {
                files:[],
                sqls:0
            }
        },
        methods:{
            upgrade_check(){
                $.prompt('请输入更新密码,没有密码联系作者QQ4620337','',password=>{
                    layer.load(1)
                    $.get('?password='+password,res=>{
                        layer.closeAll()
                        layer.msg(res.msg,function(){
                            if(res.url){
                                window.location.href = res.url
                            }
                        })
                        this.files = res.data.files
                        this.sqls = res.data.sqls.length
                    })
                })
            },
            upgrade_install(){
                $.prompt('请输入更新密码,没有密码联系作者QQ4620337','',password=>{
                    $.confirm('请谨慎操作,升级前务必备份数据库和源代码',()=>{
                        $.submit('',{password:password});
                    })
                })
            }
        }
    })
</script>
{/block}